﻿<%@ Page Title="Admins" Language="C#" MasterPageFile="~/MasterPages/Frontend.master" AutoEventWireup="true" CodeFile="Admins.aspx.cs" Inherits="Admin_Admins" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="RoleId,UserId" DataSourceID="SqlDataSource1" AllowPaging="True" AllowSorting="True">
                <Columns>
                    <asp:CommandField DeleteText="Delete from admin" ShowDeleteButton="True" />
                    <asp:BoundField DataField="UserName" HeaderText="UserName" SortExpression="UserName" />
                    <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
                </Columns>
            </asp:GridView>
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ProjectASPConnectionString %>" DeleteCommand="DELETE FROM aspnet_UsersInRoles WHERE UserId=@UserId and RoleId=@RoleId" SelectCommand="SELECT aspnet_Roles.RoleName, aspnet_UsersInRoles.RoleId, aspnet_UsersInRoles.UserId, aspnet_Users.UserName, aspnet_Membership.Email FROM aspnet_UsersInRoles INNER JOIN aspnet_Users ON aspnet_UsersInRoles.UserId = aspnet_Users.UserId INNER JOIN aspnet_Roles ON aspnet_UsersInRoles.RoleId = aspnet_Roles.RoleId INNER JOIN aspnet_Membership ON aspnet_Users.UserId = aspnet_Membership.UserId"></asp:SqlDataSource>
            <asp:DropDownList ID="UserList" runat="server" DataSourceID="SqlDataSource2" DataTextField="UserName" DataValueField="UserName">
            </asp:DropDownList>
            <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ProjectASPConnectionString %>" SelectCommand="SELECT UserId, UserName FROM aspnet_Users WHERE (UserId NOT IN (SELECT UserId FROM aspnet_UsersInRoles))"></asp:SqlDataSource>
            <asp:Button ID="Button1" runat="server" Text="Make admin" OnClick="Button1_Click" />
            <br />
            <asp:Button ID="Button2" runat="server" Text="Back" PostBackUrl="~/Admin/Default.aspx" />
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>

